import { defineStore } from 'pinia'
import {selectInfo} from "../request/request";
/**
 * @param{{用户权限}}
 */
export const usePermissions = defineStore({
    id: 'data',
    state: () => {
        return {
            userPermissions:'',//权限
            user:'',//用户信息
        }
    },
    actions:{
      updataPermissions(e){
          this.userPermissions=e//更新权限
      },
        updataUser(){
            selectInfo().then((res)=>{if (res.code==200){res.data.openid='';this.user=res.data;}})
        },
        setUser(e){
          this.user=e
        }
    },
    // 开启数据缓存
    persist: {
        enabled: true,
        strategies: [
            {
                key: 'permissions',
                storage: localStorage,
                paths: ['userPermissions']
            },
            {
                key: 'my_user',
                storage: localStorage,
                paths: ['user']
            }
        ]
    }
})


